<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function extend(sub, sup) {
        sub.prototype = Object.create(sup.prototype);
        sub.prototype.constructor = sub;
      }
      function User(name, age) {
        this.name = name;
        this.age = age;
      }
      User.prototype.show = function () {
        console.log(this.name, this.age);
      };
      const Request = {
        ajax() {
          return '请求后台';
        },
      };
      const Credit = {
        __proto__: Request,
        total() {
          console.log(super.ajax() + ',统计积分');
        },
      };

      console.log(Credit);
      function Admin(...args) {
        User.apply(this, args);
      }
      extend(Admin, User);
      Object.assign(Admin.prototype, Request, Credit);
      let hd = new Admin('向军', 19);
      hd.show();
      hd.total(); //统计积分
      hd.ajax(); //请求后台
    </script>
  </body>
</html>
